package cn.tedu.yl.TCLX.controller;


import cn.tedu.yl.TCLX.pojo.Type;
import cn.tedu.yl.TCLX.service.TypeService;
import cn.tedu.yl.base.response.JsonResult;
import cn.tedu.yl.base.response.PageData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "体检类型模块")
@RestController
@RequestMapping("/v1/type")
@Slf4j
public class TypeController {
    @Autowired
    private TypeService typeService;

    @GetMapping("/select")
    private JsonResult select(){
        log.debug("查询所有类型");
        PageData list =typeService.getAll();
        return JsonResult.ok(list);
    }

    @PostMapping("/create")
    private JsonResult create(@RequestBody Type type){
        log.debug("创建类型:{}",type);
        typeService.create(type);
        return JsonResult.ok();
    }
    @PostMapping("/delete/{id}")
    private JsonResult delete(@PathVariable(value = "id") Long id){
        log.debug("删除类型id:{}",id);
        typeService.delete(id);
        return JsonResult.ok();
    }

    @PostMapping("/update/{id}")
    private JsonResult update(@PathVariable(value = "id") Long id,@RequestBody Type type){
        log.debug("修改类型:{}",type);
        typeService.update(id,type);
        return JsonResult.ok();
    }
}
